﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace cwdz
{
    public partial class showbody : System.Web.UI.Page
    {
        decimal _WJTOTAL_TOTAL = 0m;
        //decimal _JTAXTOTAL13_TOTAL = 0m;
        //decimal _JTAXTOTAL17_TOTAL = 0m;
        decimal _JTAXTOTAL_TOTAL = 0m;
        decimal _HJTOTAL_TOTAL = 0m;
        decimal _KXTOTAL_TOTAL = 0m;

        //String sqlCommand = "SELECT YWORGNAME,BILLNO,YWBILLNO,REMARK,CASE JTAXRATE WHEN 17 THEN SUM(JTaxTotal) END AS TaT17,CASE JTAXRATE WHEN 13 THEN SUM(JTaxTotal) END AS TaT13, SUM(WJTOTAL) AS WJTOTAL,SUM(HJTOTAL) AS HJTOTAL FROM TACPJSJXBODY WHERE (BILLNO = ?) GROUP BY YWORGNAME,BILLNO,YWBILLNO,REMARK,JTAXRATE ORDER BY YWBILLNO";

        protected void Page_Load(object sender, EventArgs e)
        {
            BillNoLabel.Text = Request["billNo"];
            OrgNameLabel.Text = Request["OrgName"];
            SupCodeLabel.Text = Request["SupCode"];
            SupNameLabel.Text = Request["SupName"];
            HtCodeLabel.Text = Request["HtCode"];
            HtNameLabel.Text = Request["HtName"];

            Label_HtCode.Text = Request["HtCode"];
            Label_HtName.Text = Request["HtName"];
            Label_SupCode.Text = Request["SupCode"];
            Label_SupName.Text = Request["SupName"];

            DateTime getNow = DateTime.Now;
            showDateLabel.Text = getNow.ToString();

            //OrgNameLabel.Text = BodyGridView.Rows[1].Cells[1].Text;

            HyperLink_bodyDetail.NavigateUrl = "~/bodyDetail.aspx?BillNo=" + Request["billNo"];
        }

        protected void bodyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                System.Data.DataRowView totalRows = (System.Data.DataRowView)e.Row.DataItem;

                //_WJTOTAL_TOTAL += Convert.ToDecimal(totalRows[3].ToString());
                //_JTAXTOTAL13_TOTAL += Convert.ToDecimal(totalRows[3].ToString());
                //_JTAXTOTAL17_TOTAL += Convert.ToDecimal(totalRows[4].ToString());
                //_JTAXTOTAL_TOTAL += Convert.ToDecimal(totalRows[4].ToString());
                _HJTOTAL_TOTAL += Convert.ToDecimal(totalRows[4].ToString());

                //OrgNameLabel.Text += totalRows[0].ToString();
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "合计：";
                //e.Row.Cells[1].Text = "合计：";
                //e.Row.Cells[2].Text = "合计：";
                //e.Row.Cells[3].Text = "合计：";
                //e.Row.Cells[3].Text = _WJTOTAL_TOTAL.ToString();
                //e.Row.Cells[3].Text = _JTAXTOTAL13_TOTAL.ToString();
                //e.Row.Cells[4].Text = _JTAXTOTAL17_TOTAL.ToString();
                //e.Row.Cells[5].Text = _JTAXTOTAL_TOTAL.ToString();
                e.Row.Cells[5].Text = _HJTOTAL_TOTAL.ToString();
            }

        }
        protected void jTaxInfo_RowDataBound(object sender, GridViewRowEventArgs e1)
        {
            if (e1.Row.RowType == DataControlRowType.DataRow)
            {

                System.Data.DataRowView totalRows = (System.Data.DataRowView)e1.Row.DataItem;

                //_KXTOTAL_TOTAL += Convert.ToDecimal(totalRows[0].ToString());
                //_KXTOTAL_TOTAL += Convert.ToDecimal(totalRows[1].ToString());
                //_KXTOTAL_TOTAL += Convert.ToDecimal(totalRows[1].ToString());
                _WJTOTAL_TOTAL += Convert.ToDecimal(totalRows[3].ToString());
                //_JTAXTOTAL13_TOTAL += Convert.ToDecimal(totalRows[3].ToString());
                //_JTAXTOTAL17_TOTAL += Convert.ToDecimal(totalRows[4].ToString());
                //_JTAXTOTAL_TOTAL += Convert.ToDecimal(totalRows[2].ToString());
                _JTAXTOTAL_TOTAL += Convert.ToDecimal(totalRows[2].ToString());
                //_HJTOTAL_TOTAL += Convert.ToDecimal(totalRows[1].ToString());

            }
            else if (e1.Row.RowType == DataControlRowType.Footer)
            {
                e1.Row.Cells[0].Text = "合计：";
                e1.Row.Cells[1].Text = _HJTOTAL_TOTAL.ToString();
                e1.Row.Cells[4].Text = _WJTOTAL_TOTAL.ToString();
                e1.Row.Cells[3].Text = _JTAXTOTAL_TOTAL.ToString();

            }

        }
        protected void tAcpJsKxGridView_RowDataBound(object sender, GridViewRowEventArgs e2)
        {
            if (e2.Row.RowType == DataControlRowType.DataRow)
            {

                System.Data.DataRowView totalRows = (System.Data.DataRowView)e2.Row.DataItem;

                //_KXTOTAL_TOTAL += Convert.ToDecimal(totalRows[0].ToString());
                //_KXTOTAL_TOTAL += Convert.ToDecimal(totalRows[1].ToString());
                _KXTOTAL_TOTAL += Convert.ToDecimal(totalRows[1].ToString());

            }
            else if (e2.Row.RowType == DataControlRowType.Footer)
            {
                e2.Row.Cells[0].Text = "合计：";
                e2.Row.Cells[1].Text = _KXTOTAL_TOTAL.ToString();
                //e.Row.Cells[3].Text = "3";

            }

        }
    }
}